'''
Created on Dec 16, 2010

@author: mwicat
'''

import core


try:
    from SimpleXMLRPCServer import SimpleXMLRPCServer
except ImportError:
    from sniffylib.util.SimpleXMLRPCServer import SimpleXMLRPCServer
    

class XmlRpc(core.BaseRPCService):
    
    def __init__(self, addr):
        self.server = SimpleXMLRPCServer(addr, allow_none=True)
        self.server_thread = Service(self.server.handle_request)
    
    def register(self, f, name):
        self.server.register_function(f, name)
        
    def start_service(self):
        self.server_thread.start()
        
    def stop_service(self):
        self.server_thread.stop()

